﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class Solution11
{
    public int MaxArea(int[] height)
    {
        int max = 0;


        int len=height.Length;
        int left = 0;
        int right = len-1;

        int width = 0;
        int h = 0;
        //桶的容量是由最短板决定的，所有每次移动较短的板
        while (left < right)
        {
          


            h = Math.Min(height[left], height[right]);
            width=right-left;
            int curArea=h*width;
            max = Math.Max(max, curArea);

            if(height[left]< height[right])
            {
                left++;
               
              
            }
            else
            {
                right--;

            }

           


        }

        return max;


    }
}

class Program11
{


    static void Main11(string[] args)
    {
        Solution11 solution = new Solution11();

        int[] nums = [1, 8, 6, 2, 5, 4, 8, 3, 7];
     int res=   solution.MaxArea(nums);
        Console.WriteLine(res);

    }
}
